export default {
  lazyImg: {
    mounted (dom, obj) {
      // 设置默认图片
      dom.src = require('@/assets/images/200.png')
      // 是否进入可视区域
      const ob = new IntersectionObserver(([{ isIntersecting }]) => {
        if (isIntersecting) {
          dom.src = obj.value
          ob.unobserve(dom)
        }
      })
      // 启动
      ob.observe(dom)
      // 图片地址出错
      dom.onerror = function () {
        dom.src = require('@/assets/images/200.png')
      }
    }
  }
}
